package com.xxrl.shop.service;

import com.xxrl.shop.domain.User;
import com.xxrl.shop.domain.UserInfo;
import com.xxrl.shop.repository.UserInfoRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author mis
 */
@Service
public class UserInfoService {

    private final UserInfoRepository userInfoRepository;

    @Autowired
    public UserInfoService(UserInfoRepository userInfoRepository) {
        this.userInfoRepository = userInfoRepository;
    }

    public UserInfo getInfoByUser(User user) {
        return userInfoRepository.queryUserInfoByUser(user);
    }

    public void updateUserInfoByUser(User user, UserInfo userInfo) {
        userInfo.setUser(user);
        userInfoRepository.save(userInfo);
    }
}
